#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
配置文件
Configuration file for AI Content Reliability Detection System
"""

import os
from typing import Dict

class Config:
    """系统配置类"""
    
    # API密钥配置
    API_KEYS = {
        'zerogpt': os.getenv('ZEROGPT_API_KEY', ''),
        'openai': os.getenv('OPENAI_API_KEY', ''),
        'anthropic': os.getenv('ANTHROPIC_API_KEY', ''),
        'cohere': os.getenv('COHERE_API_KEY', '')
    }
    
    # 检测阈值配置
    DETECTION_THRESHOLDS = {
        'ai_probability_high': 0.8,    # AI生成概率高阈值
        'ai_probability_low': 0.3,     # AI生成概率低阈值
        'reliability_threshold': 0.3,  # 可靠性评分阈值
        'quality_threshold': 0.5       # 质量评分阈值
    }
    
    # 知识库配置
    KNOWLEDGE_BASE_CONFIG = {
        'path': 'knowledge_base',
        'max_search_results': 10,
        'similarity_threshold': 0.7
    }
    
    # 质量过滤配置
    QUALITY_FILTER_CONFIG = {
        'min_content_length': 50,
        'max_extreme_emotion_ratio': 0.1,
        'max_extreme_opinion_ratio': 0.15,
        'trusted_domains': [
            'arxiv.org',
            'sciencedirect.com',
            'ieeexplore.ieee.org',
            'gov.cn',
            'moe.gov.cn',
            'cnki.net',
            'wanfangdata.com.cn',
            'springer.com',
            'nature.com',
            'science.org'
        ]
    }
    
    # 日志配置
    LOGGING_CONFIG = {
        'level': 'INFO',
        'format': '%(asctime)s - %(levelname)s - %(message)s',
        'file': 'ai_detector.log',
        'max_file_size': 10 * 1024 * 1024,  # 10MB
        'backup_count': 5
    }
    
    # HTTP请求配置
    HTTP_CONFIG = {
        'timeout': 30,
        'max_retries': 3,
        'retry_delay': 1
    }
    
    @classmethod
    def get_api_keys(cls) -> Dict[str, str]:
        """获取API密钥"""
        return cls.API_KEYS.copy()
    
    @classmethod
    def get_detection_thresholds(cls) -> Dict[str, float]:
        """获取检测阈值"""
        return cls.DETECTION_THRESHOLDS.copy()
    
    @classmethod
    def get_knowledge_base_config(cls) -> Dict:
        """获取知识库配置"""
        return cls.KNOWLEDGE_BASE_CONFIG.copy()
    
    @classmethod
    def get_quality_filter_config(cls) -> Dict:
        """获取质量过滤配置"""
        return cls.QUALITY_FILTER_CONFIG.copy()
    
    @classmethod
    def get_logging_config(cls) -> Dict:
        """获取日志配置"""
        return cls.LOGGING_CONFIG.copy()
    
    @classmethod
    def get_http_config(cls) -> Dict:
        """获取HTTP配置"""
        return cls.HTTP_CONFIG.copy()

# 环境变量配置示例
ENV_VARS_EXAMPLE = """
# 在系统环境变量中设置以下变量（可选）：
export ZEROGPT_API_KEY="your_zerogpt_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
export COHERE_API_KEY="your_cohere_api_key_here"
""" 